package com.kotiln.lgc.lib_base.utils

import com.google.gson.Gson
import okhttp3.MediaType
import okhttp3.RequestBody

/**
 *@fileName ParamsUtils
 *@date2021/4/28  15:55
 *@author ParamsUtils$
 *@describe TODO
 *@desc Retrofit post请求中的 body 参数工具类
 */
object ParamsUtils {

    fun getRequestBody(params: MutableMap<String, Any>?): RequestBody {
        val bodyMap = HashMap<String, Any>()
        bodyMap["avm"] = "99219136"
        bodyMap["datetime"] = "20210422140255"
        bodyMap["myappid"] = "1e435435798jr5fhh98r41sadnrd89ffh0ebcf73e544"
        bodyMap["sign"] = "4d9527145ab9700e43a48b54df41ea31"
        params?.let {
            bodyMap.putAll(it)
        }
        return RequestBody.create(MediaType.parse("application/json;charset=utf-8"), Gson().toJson(bodyMap))
    }
}